package com.ruoyi.car.controller.carmanage;

import java.util.List;

import com.car.pojo.TbCarOperation;
import com.ruoyi.car.service.carmanage.TbCarOperationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆运营表Controller
 * 
 * @author 仲晓天
 *
 */
@Controller
@RequestMapping("/carmanage/operation")
public class TbCarOperationController extends BaseController {

    private String prefix = "carmanage/operation";

    @Autowired
    private TbCarOperationService tbCarOperationService;

    @RequiresPermissions("carmanage:operation:view")
    @GetMapping()
    public String operation()
    {
        return prefix + "/operation";
    }

    /**
     * 查询车辆运营表列表
     */
    @RequiresPermissions("carmanage:operation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbCarOperation tbCarOperation)
    {
        startPage();
        System.out.println("---------------"+tbCarOperation.toString());
        List<TbCarOperation> list = tbCarOperationService.selectTbCarOperationList(tbCarOperation);
        return getDataTable(list);
    }



    /**
     * 新增车辆运营表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存车辆运营表
     */
    @PostMapping("/addOperation")
    @ResponseBody
    public AjaxResult addOperation(TbCarOperation tbCarOperation)
    {
        return toAjax(tbCarOperationService.insertTbCarOperation(tbCarOperation));
    }

    /**
     * 修改车辆运营表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TbCarOperation tbCarOperation = tbCarOperationService.selectTbCarOperationById(id);
        mmap.put("tbCarOperation", tbCarOperation);
        return prefix + "/edit";
    }

    /**
     * 修改保存车辆运营表
     */
    @PostMapping("/updateOperation")
    @ResponseBody
    public AjaxResult updateOperation(TbCarOperation tbCarOperation)
    {
        return toAjax(tbCarOperationService.updateTbCarOperation(tbCarOperation));
    }


    /**
     * 删除车辆运营表
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbCarOperationService.deleteTbCarOperationByIds(ids));
    }
}
